package com.visionblue.business.ship.model.repository.db

import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.Ignore
import androidx.room.PrimaryKey
import com.visionblue.business.ship.model.enums.WasteTypeEnum
import com.visionblue.business.ship.view.refresh.StatusTypeInterfaceImpl

/**
 * @author: xlh
 * @date: 2020-05-21 10:48 AM
 * @desc:
 */
@Entity(tableName = "collection_record")
data class CollectionRecord(
    // 废物类型
    @ColumnInfo(name = "waste_type")
    var wasteType: String = "",
    // 废物重量或体积
    @ColumnInfo(name = "accumulation_FlowUnit")
    var accumulationFlowUnit: String =" 0f",
    // 累计单位
    @ColumnInfo(name = "origin_weight")
    var originWeight: Float = 0f,
    // 校准后的重量或体积
    @ColumnInfo(name = "final_weight")
    var finalWeight: Float? = null,
    // 收集开始时间
    @ColumnInfo(name = "start_time")
    var startTime: Long = -1L,
    // 收集结束时间
    @ColumnInfo(name = "end_time")
    var endTime: Long? = null,
    @ColumnInfo(name = "cached_order_id")
    var cachedOrderId: Long? = null,
    @Ignore
    var alias: String? = null,
    @PrimaryKey(autoGenerate = true)
    var id: Long? = null
) : StatusTypeInterfaceImpl() {


    fun getShowWeight(): Float? {
        if (finalWeight != null) {
            return finalWeight
        }

        return originWeight
    }

    override fun equals(other: Any?): Boolean {
        if (this === other) return true
        if (javaClass != other?.javaClass) return false

        other as CollectionRecord

        if (id != other.id) return false

        return true
    }

    override fun hashCode(): Int {
        return id?.hashCode() ?: 0
    }


}